package com.jie.jie.andfix;

import android.os.Bundle;
import android.os.Environment;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;

import com.jaydenxiao.common.commonutils.ToastUitl;
import com.jie.jie.MyApplication;
import com.jie.jie.R;

import java.io.IOException;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class AndFixActivity extends AppCompatActivity {

    @Bind(R.id.af_btn)
    Button afBtn;
    @Bind(R.id.change_btn)
    Button changeBtn;
    @Bind(R.id.activity_and_fix)
    LinearLayout activityAndFix;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_and_fix);
        ButterKnife.bind(this);
    }

    @OnClick({R.id.af_btn, R.id.change_btn})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.af_btn:
                showToast();
                break;
            case R.id.change_btn:
                String patchPath = Environment.getExternalStorageDirectory() + "/first.apatch";
                try {
                    MyApplication.getInstance().getPatchManager().addPatch(patchPath);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                break;
        }
    }

    private void showToast() {
        ToastUitl.show("bug", 1000);
    }
}
